package com.wh.shiroswagger.realm;

import com.wh.shiroswagger.service.UserService;
import com.wh.shiroswagger.token.MyToken;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Auther: HuiEr
 * @Date: 2020/3/5 22:51
 * @Description
 */
public class CustomCredentialMatcher extends HashedCredentialsMatcher {
    @Autowired
    private UserService userService;
    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        MyToken myToken=(MyToken) token;
        String token1 = myToken.getToken();
        boolean b = userService.tokenExistOrNot(token1);
        return b;
    }
}
